package com.lxl.controller;

import com.lxl.pojo.BaseResponse;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ErrorHandlerController implements ErrorController {

    @Override
    public String getErrorPath() {
        return "/error";
    }

    @RequestMapping(value = "/error", method = {RequestMethod.GET,RequestMethod.POST}, produces = "application/json;charset=UTF-8")
    public BaseResponse error() {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.exception();
        baseResponse.setData("出现异常");
        return baseResponse;
    }
}
